/**
 * 获取url中参数的值
 * @param name  url中的参数"?name=123"
 * @returns {null} 返回对应的值
 */
function getQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}


/**
 * 获取openId
 * @returns {string} openId
 */
function getOpenId() {
    return window.localStorage.getItem("currentLoginOpenId");
};

/**
 * @param timeSet 考试设置时间
 * @param timeOut  考试倒计时时间
 * @returns {string} 考试所用时长
 */
function getUseTime(timeSet,timeOut){
    var minute = timeOut.split(":")[0];
    var second = timeOut.split(":")[1];
    var useTime = "";
    if(second == "00"){
        var minuteResult = parseInt(timeSet) - parseInt(minute);
        if(minuteResult<10){
            minuteResult = "0"+minuteResult;
        }
        useTime += minuteResult +":00"
    }else{
        var minuteResult = parseInt(timeSet) - 1 - parseInt(minute);
        var secondResult = 60 - parseInt(second);
        if(minuteResult<10){
            minuteResult = "0"+minuteResult;
        }
        if(secondResult<10){
            secondResult = "0"+secondResult;
        }
        useTime += minuteResult + ":" + secondResult;
    }
    return useTime;
}
function replaceChat(source,pos,newChar){
    if(pos<0||pos>=source.length||source.length==0){
        return "invalid parameters...";
    }
    var iBeginPos= 0, iEndPos=source.length;
    var sFrontPart=source.substr(iBeginPos,pos);
    var sTailPart=source.substr(pos+1,source.length);
    var sRet=sFrontPart+newChar+sTailPart;
    return sRet;
}